package com.netrust.cmsx.core.persist;

import java.util.List;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import com.google.common.collect.Lists;

/**
 * 树
 */
@MappedSuperclass
public abstract class TreeEntity<T> extends DataEntity<T> {
	private static final long serialVersionUID = 7225882681055881835L;
	
	@Column(name = "parent_id")
	protected String pid;

	@Transient
	protected T parent;	// 父级菜单
	
	@Transient
	protected boolean expanded = false;	//jqgrid 专用
	
	@Transient
	protected boolean isLeaf = true;	//jqgrid 专用
	
	@Transient
	protected Integer level;	//jqgrid 专用
	
	@Transient
	protected List<T> children=Lists.newArrayList();		// 根据用户ID查询角色列表
	
	public TreeEntity() {
	}
	
	public TreeEntity(String id) {
		super(id);
	}

	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	public T getParent() {
		return parent;
	}

	public void setParent(T parent) {
		this.parent = parent;
	}

	public List<T> getChildren() {
		return children;
	}

	public void setChildren(List<T> children) {
		this.children = children;
	}

	public boolean isExpanded() {
		return expanded;
	}

	public void setExpanded(boolean expanded) {
		this.expanded = expanded;
	}

	public boolean getIsLeaf() {
		return isLeaf;
	}

	public void setIsLeaf(boolean isLeaf) {
		this.isLeaf = isLeaf;
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}
	
	
}
